home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / misc / nnn.lha / nnn1.35 / src / NetVecRand.c < prev    next >
C/C++ Source or Header  |  1995-03-20  |  1KB  |  64 lines

  1. /*
  2.  *  $Id: NetVecRand.c 1.3 1995/03/14 23:11:41 daltern Exp $
  3.  *
  4.  *    Function    NetVecRand
  5.  *    Programmer    Nicholas d'Alterio
  6.  *    Date        15/01/95
  7.  *
  8.  *  Synopsis:    This randomises the order of a set of vectors by 
  9.  *        swapping random rows many times.
  10.  *
  11.  *  $Log: NetVecRand.c $
  12.  * Revision 1.3  1995/03/14  23:11:41  daltern
  13.  * Added comments and cleaned up
  14.  *
  15.  *
  16.  */
  17.  
  18. #include "Neural.h"
  19.  
  20. void NetVecRand( VECTOR *vec )
  21.  
  22.  {
  23.  
  24.   register int i;
  25.  
  26.   int    row1;
  27.   int    row2;
  28.  
  29.   float *temp_in_row;
  30.   float *temp_out_row;
  31.  
  32. /*
  33.  * Randomise data sets by swapping 2 random rows NUM_RAND_STEPS times.
  34.  */
  35.  
  36.   for ( i = 0; i < NUM_RAND_STEPS; i++ ) {
  37.  
  38.  
  39. /*
  40.  *  Get 2 random rows to swap.
  41.  */
  42.  
  43.     row1 = (int)((vec->NumVecs-1) * RAND_FUNC());              
  44.     row2 = (int)((vec->NumVecs-1) * RAND_FUNC());
  45.  
  46. /*
  47.  *  Swap rows over.
  48.  */
  49.  
  50.     temp_in_row       = vec->InVec[row1];
  51.     temp_out_row      = vec->OutVec[row1];
  52.     vec->InVec[row1]  = vec->InVec[row2];
  53.     vec->OutVec[row1] = vec->OutVec[row2];
  54.     vec->InVec[row2]  = temp_in_row;
  55.     vec->OutVec[row2] = temp_out_row;
  56.  
  57.  
  58.   }   /* end for i */
  59.  
  60.  return;
  61.  
  62.  }   /* end function NetVecRand */
  63.  
  64.